#include "widget.h"
#include "ui_widget.h"

Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    //设置两个lineEdit的echoMode
    ui->lineEdit->setEchoMode(QLineEdit::Password);
    ui->lineEdit_2->setEchoMode(QLineEdit::Password);

}

Widget::~Widget()
{
    delete ui;
}


void Widget::on_lineEdit_textEdited(const QString &arg1)
{
    //获取另一个编辑框的文本
    const QString &other = ui->lineEdit_2->text();

    compare(arg1,other);
}

void Widget::on_lineEdit_2_textEdited(const QString &arg1)
{
     //获取另一个编辑框的文本
    const QString &other = ui->lineEdit->text();

    compare(arg1,other);
}

void Widget::compare(const QString &arg1,const QString &other)
{
     if(arg1.isEmpty() && other.isEmpty()){
        ui->label_title->setText("密码为空");
     }else if(arg1 == other){
         ui->label_title->setText("两次输入的密码一致");
     }else{
         ui->label_title->setText("两次输入的密码不一致");
     }
}
